import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class FileInputStreamTest2 {
    public static void main(String[] args) throws Exception {
        InputStream is = new FileInputStream("IO\\IO\\FileInputStream\\bbb.txt");

        // 开始读取文件中的字节数据：每次读取多个字节
        // byte[] buffer = new byte[3];
        // int len = is.read(buffer);
        // String rs = new String(buffer);
        // System.out.println(rs);
        // System.out.println("每次读取的字节数量:" + len);

        // int len2 = is.read(buffer);
        // // 读取多少，倒出多少
        // String rs2 = new String(buffer, 0, len2);
        // System.out.println(rs2);
        // System.out.println("当次读取的字节数量:" + len2);

        // 使用循环改造
        byte[] buffer = new byte[3];
        int len;
        while ((len = is.read(buffer)) != -1) {
            String rs = new String(buffer, 0, len);
            System.out.println(rs);
        }

        is.close();
    }
}
